package com.example.permissionserviceconsumer.service;

import com.myprojects.common.pojo.UserWithRole;
import com.myprojects.common.dto.Msg;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@Service
@FeignClient(name = "permission-service",
        contextId = "user-with-role-api1",
        fallback = FeignUserWithRoleServiceFallback.class)
public interface FeignUserWithRoleService {

    /**
     * 该方法用于获取全部的角色
     */
    @RequestMapping(value = "/user-curd/roles", method = RequestMethod.GET)
    @ResponseBody
    public Msg getAllRoles();

    /**
     * 该方法用于分页查询所有的用户信息(非员工)
     */
    @RequestMapping(value = "/user-curd/users", method = RequestMethod.GET)
    @ResponseBody
    public Msg selectUsersByPageNum(
            @RequestParam(value = "pn", defaultValue = "1") Integer pageNum,
            @RequestParam(value = "size", defaultValue = "10") Integer pageSize,
            @RequestParam(value = "search", defaultValue = "") String searchStr
    );

    /**
     * 该方法用于检查更新用户的信息
     */
    @RequestMapping(value = "/user-curd/check-user", method = RequestMethod.POST)
    @ResponseBody
    public Msg checkNewUser(UserWithRole user);

    /**
     * 该方法用于检查更新用户的信息
     */
    @RequestMapping(value = "/user-curd/check-user", method = RequestMethod.PUT)
    @ResponseBody
    public Msg checkUpdateUser(UserWithRole user);

    /**
     * 该方法用于保存用户
     */
    @RequestMapping(value = "/user-curd/users", method = RequestMethod.POST)
    @ResponseBody
    public Msg saveUser(@RequestBody UserWithRole user);

    /**
     * 该方法用于更新用户(该方法会更新用户所拥有的角色)
     */
    @RequestMapping(value = "/user-curd/users", method = RequestMethod.PUT)
    @ResponseBody
    public Msg updateUser(@RequestBody UserWithRole user);

//    /**
//     * 该方法用于更新用户(该方法不会更新用户所拥有的角色)
//     */
//    @RequestMapping(value = "/user-curd/users_without_role", method = RequestMethod.PUT)
//    @ResponseBody
//    public Msg updateUserWithoutRole(@RequestBody UserWithRole user);
//
//    /**
//     * 该方法用于检查更新用户的信息
//     */
//    @RequestMapping(value = "/user-curd/users_without_role", method = RequestMethod.POST)
//    @ResponseBody
//    public Msg checkUserWithoutRole(@RequestBody UserWithRole user);

    /**
     * 该方法用于一次删除多个用户
     */
    @RequestMapping(value = "/user-curd/users", method = RequestMethod.DELETE)
    @ResponseBody
    public Msg deleteLotsUser(@RequestParam List<Integer> idList);

}
